package com.cupcorn.lib.player;

import java.io.IOException;

import com.cupcorn.lib.game.GameEngine;
import com.cupcorn.lib.game.GameMusic;
import com.cupcorn.lib.game.element.GameElementMusic;

public class PlayerMusic
{
	GameElementMusic[]	gameElementMusic;
	public GameMusic[]	music;
	
	public PlayerMusic(GameEngine engine, GameElementMusic[] gameElementMusic)
	{
		this.gameElementMusic = gameElementMusic;
		music = new GameMusic[gameElementMusic.length];
		
		try
		{
			for (int i = 0; i < gameElementMusic.length; i++)
			{
				music[i] = new GameMusic(engine, gameElementMusic[i]);
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
	
	public GameMusic newMusic(int index)
	{
		music[index].play();
		return music[index];
	}
	
	public void pauseAll()
	{
		for (int i = 0; i < gameElementMusic.length; i++)
		{
			music[i].pause();
		}
	}
	
	public void resumeAll()
	{
		for (int i = 0; i < gameElementMusic.length; i++)
		{
			music[i].resume();
		}
	}
}
